package info.wangyuan.springbootdemo.mapper;

import info.wangyuan.springbootdemo.entity.Book;
import org.apache.ibatis.annotations.*;

/**
 * 书籍接口数据访问层
 *
 * @author Albert
 * @since 2025-10-30 17:51:34
 */
@Mapper
public interface BookMapper {

    /**
     * 保存书籍
     */
    @Insert("insert into book(title, author, price) values(#{title}, #{author}, #{price})")
    void save(Book book);

    /**
     * 根据 id 查询书籍
     */
    @Select("select * from book where id = #{id}")
    Book getById(Integer id);

    /**
     * 根据 id 修改书籍
     */
    @Update("update book set title = #{title}, author = #{author}, price = #{price} where id = #{id}")
    void updateById(Book book);

    /**
     * 根据 id 删除书籍
     */
    @Delete("delete from book where id = #{id}")
    void deleteById(Integer id);
}
